import axios from 'axios'
import { Notification } from 'element-ui'
const service = axios.create({
  baseURL: 'http://127.0.0.1:3500',
  timeout: 5000
})

service.interceptors.request.use(
  (conf) => {
    return conf
  },
  (error) => {
    return Promise.reject(error)
  }
)
/*
* -20000: "帐号未注册",
-20001: "帐号已注册",
-20002: "手机号码已注册",
-20003: "手机号码未注册",
-20004: "密码错误",
-20005: "登录失败",
-20006: "注册失败",
-20007: "帐号错误",
-20008: "手机号错误",
-20009: "没有此用户",
-20010: "评论添加失败"
*/
service.interceptors.response.use(
  (conf) => {
    if (conf.data.status !== 0) {
      Notification.error(conf.data.msg)
    }
    return conf
  },
  (error) => {
    return Promise.reject(error)
  }
)

export default service
